<!--
  - ViewOtherAnalysis.php
  - v1.3
  - 4/02/2011
  -->

<!--
  - Code Specifications:
  - This code gathers the inputs for all other analysis, which can only be
  - viewed by the analyst. After inputting values, the results are forwarded to
  - ControllerOtherAnalysis.php for values computation and database updating.
  -->
	
<?php
	//Gets required libraries
	require '../libraries/UserLibrary.php';
	require '../libraries/EditAnalysisLib.php';
	
	//Formally starts session
	session_start();
	
	//Ensures that the analyst is logged in.
	isSessionSet("analyst", null, "../Logout.php");

	//Gathers some information from the controller
	if(isset($_GET['mainType']) && isset($_GET['subType']) && isset($_GET['analysisRequired']) && isset($_GET['year']) && isset($_GET['no'])){
		$_SESSION['mainType'] =  $_GET['mainType'];
		$_SESSION['subType'] = $_GET['subType'];
		$_SESSION['year'] = $_GET['year'];
		$_SESSION['no'] = $_GET['no'];
		$_SESSION['analysisRequired'] = $_GET['analysisRequired'];
	}
?>	
<!-- HTML markup -->
<html>
	<head>
		<title>CASLIMS | Other Analysis</title>
		<link rel="stylesheet" type="text/css" href="../scripts/page.css" />
		<script type="text/javascript" src="../scripts/validateParameterInput.js"></script>
		<link href="../tools/favicon.ico" rel="shortcut icon" type="image/x-icon" />
	</head>
	<body>
		<div id="header"></div>
		<div id="wrapper">
			<div id="pagetop">
				<div class="greeting">Hi, <?php echo $_SESSION["analyst"];?> | <a href="../Logout.php">Log out</a> | <a href="../AnalystHomepage.php"> Home </a></div>
				<div class="homepage"><?php echo $_SESSION["analyst"];?></div>
			</div>
			<form name="viewOtherAnalysis" method="post" action="ControllerOtherAnalysis.php">
			<h4>CASL No: <?php printf("%d-%04d", $_SESSION["year"], $_SESSION["no"]); ?></h4>
				<table border='0'>
					<?php
						$con = mysql_connect('localhost','editanalysis','editanalysis') or die('Could not connect: ' . mysql_error());
						mysql_select_db('casl') or die(mysql_error());
						$result = getLimitedTable($_SESSION['year'], $_SESSION['no'], $_SESSION['mainType'], $_SESSION['subType'], $_SESSION['analysisRequired'], "casl", "localhost", "editanalysis", "editanalysis");
						$id = getID($_SESSION['year'], $_SESSION['no'], $_SESSION['mainType'], $_SESSION['subType'], $_SESSION['analysisRequired'], "casl", "localhost", "editanalysis", "editanalysis");
						$val1 = getValue("value1", $id, $_SESSION['year'], $_SESSION['no'], "casl", "localhost", "editanalysis", "editanalysis");
						$val2 = getValue("value2", $id, $_SESSION['year'], $_SESSION['no'], "casl", "localhost", "editanalysis", "editanalysis");
						$val3 = getValue("value3", $id, $_SESSION['year'], $_SESSION['no'], "casl", "localhost", "editanalysis", "editanalysis");
						$mean = getMean($_SESSION['year'], $_SESSION['no'], "casl", "localhost", "editanalysis", "editanalysis");
						$standardDev = getStandardDev($_SESSION['year'], $_SESSION['no'], "casl", "localhost", "editanalysis", "editanalysis");
						$one = "disabled";
						$two = "disabled";
						$three = "";
					?>
					<thead>
						<tr>
							<th>ANALYSIS CATEGORY</th>
							<th align = "left"><input type = "checkbox" name = "value[]" id = "c1" onchange = "enable(this,<?php echo "$id";?>)"/><label for = "c1"> VALUE 1</label></th>
							<th align = "left"><input type = "checkbox" name = "value[]" id = "c2" onchange = "enable(this,<?php echo "$id";?>)"/><label for = "c2"> VALUE 2</label></th>
							<th align = "left"><input type = "checkbox" name = "value[]" id = "c3" onchange = "enable(this,<?php echo "$id";?>)"/> <label for = "c3">VALUE 3</label></th>					
						</tr>
					</thead>	 	
					<tr>
						<td><b><?php echo "$result";?></b></td>
						<td><input type = "text" name = '<?php echo "$id";?>/1' id = '<?php echo "$id";?>/1' disabled = "disabled" onKeyUp="validDecimal(this)" value =  "<?php echo"$val1"; ?>" /></td>
						<td><input type = "text" name = '<?php echo "$id";?>/2' id = '<?php echo "$id";?>/2' disabled = "disabled" onKeyUp="validDecimal(this)" value =  "<?php echo"$val2"; ?>"/></td>
						<td><input type = "text" name = '<?php echo "$id";?>/3' id = '<?php echo "$id";?>/3' disabled = "disabled" onKeyUp="validDecimal(this)" value =  "<?php echo"$val3"; ?>"/></td>
					</tr>
					<tr>
						<td><b>Mean</b></td>
						<td><div id = "mean"><?php echo "$mean"?></div></td>
					</tr>
					<tr>
						<td><b>Standard Deviation</b></td>
						<td><div id = "standardDev"><?php echo "$standardDev"?></div></td>
					</tr>
				</table>
				<br/>
				<input type="hidden" name="value1" id="value1" value="<?php echo $id; ?>/1" >
				<input type="hidden" name="value2" id="value2" value="<?php echo $id; ?>/2" >
				<input type="hidden" name="value3" id="value3" value="<?php echo $id; ?>/3" >
				<div id="buttons">
					<input type = "submit" name = "save" value = "Compute">
					<input type="button" value="Back" onClick='document.location.href = "../AnalystHomepage.php"'>			
				</div>	
			</form>
			<div id="footerwrap">
				<div id="footer"> 
					<div class="copyright">Copyright 2011.<a>CASL BIOTECH-UPLB.</a> All Rights Reserved.<br/> 
				Arianne Buse&ntilde;os | Darlene Joy Masong | Rick Jason Obrero | Jonathan Pandi | Jonathan Simbahan | Emmanuel Soriano 
					</div> 
	    	    </div>
			</div>				
		</div>			
	</body>
</html>